<template>
	<view class="">
		<scroll-view scroll-y="true" >
			<view class="content">
						<view class="profit_top">
							<view :class="day==15?'profit_b active':'profit_b'" @click="clickTab(15)">
								15天
							</view>
							<view  :class="day==30?'profit_b active':'profit_b'" @click="clickTab(30)">
								30天
							</view>
						</view>
						<view class="charts-box">
							<qiun-data-charts type="area" :opts="opts" :chartData="chartData" />
						</view>
					</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				chartData: {},
				opts: {
					color: ["#0066FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
						"#ea7ccc"
					],
					padding: [15, 15, 0, 15], // 图位置
					enableScroll: false,
					xAxis: {
						disableGrid: true,
						labelCount: 4, //设置显示个数
						// format: 'formatterTime1'
					},
					dataLabel: false, // 数据显示
					legend: false,
					dataPointShape: false, // 圆点显示
					yAxis: {
						gridType: "dash",
						dashLength: 2
					},
					extra: {
						area: {
							type: "straight",
							opacity: 0.2,
							addLine: true,
							width: 2,
							gradient: false,
							activeType: "hollow"
						}
					}
				},
				chartsDataLine1: {},
				iconInfo:{
					
				},
				day:15,
				type:null
			};
		},
		watch:{
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title:options.name
			})
			this.type = options.type
		},
		mounted() {
					this.xrDom()
				},
		onShow() {
			//模拟从服务器获取数据
			this.getServerData()
		},
		methods: {
			onUecharts(){
				let res = {
					categories: this.chartsDataLine1.date,
					series: [{
							name: "value",
							data: this.chartsDataLine1.flow
						},
					]
				};
				this.chartData = JSON.parse(JSON.stringify(res));
			},
			clickTab(day){
				this.day = day
				this.chartsDataLine1=[]
				this.getServerData()
			},
			jump(url){
				this.$fun.jump(url)
			},
			getServerData() {
				this.$fun.ajax.post('user/Kinfo',{day:this.day,type:this.type}).then(res=>{
					this.chartsDataLine1 = res.data
					this.onUecharts()
				})
			}
		}
	};
</script>

<style lang="scss">
	page{
		background: #FFFFFF;
	}
	.content {
		display: flex;
		flex-direction: column;
		flex: 1;
		background: #FFFFFF;
		
		.profit_top {
			display: flex;
			justify-content: space-around;
			margin-bottom: 100rpx;

			.profit_b {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 150rpx;
				height: 60rpx;
				background: #EEEEEE;
				border-radius: 30rpx;
				font-size: 30rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #333333;
			}

			.active {
				background: #0066FF;
				color: #FFFFFF;
			}
		}

		.charts-box {
			width: 100%;
			height: 600rpx;
			padding-right: 30rpx;
		}

		.profit_view {
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #FFFFFF;
			padding: 0 30rpx;
			box-sizing: border-box;
			font-size: 30rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: #333333;

			.g {
				color: #333333;
			}

			.r {
				color: #0066FF;
			}
		}

		.profit_list {
			padding: 24rpx 30rpx;
			background: #EEEEEE;

			.profit_title {
				font-size: 30rpx;
				font-family: Microsoft YaHei;
				color: #333333;
			}

			.profit_itemt {
				margin-top: 30rpx;
				height: 80rpx;
				background: #F6F6F6;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;

				view{
					width: 25%;
					text-align: center;
					font-size: 30rpx;
					font-family: Microsoft YaHei;
					color: #999999;
				}
				view:not(:nth-child(1)){
					text-align: left;
				}
			}

			.profit_item {
				height: 100rpx;
				background: #FFFFFF;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;
				view{
					display: flex;
					justify-content: space-between;
					width: 25%;
					font-size: 30rpx;
					font-family: Microsoft YaHei;
					color: #FF0000;
					text-align: center;

					image{
						width: 14rpx;
						height: 24rpx;
						margin-right: 20rpx;
					}
				}
				view:nth-child(1){
					width: 25%;
					color: #333333;
					display: flex;
					justify-content: center;
				}
				view:not(:nth-child(1)){
					width: 25%;
					text-align: left;
					color: #FF0000;
				}
			}
		}
	}
</style>
